<?php
namespace app\hongyanche\controller;
class Finance
{
	private function download(){
		$admin = model('admin')->is('finance');
		if(!isset($admin['state']) || !$admin['state']){
			return json($admin);
		}
		$data = [
			'start' => input('start'),
			'end' 	=> input('end'),
			'code' 	=> input('code'),
		];
    	$action = request()->action();
    	model($action)->report($data);
    	die();
	}
	function client(){
		$this->download();
	}
    function mall(){
        $this->download();
    }
	function alipay(){
		$admin = model('admin')->is('finance');
		if(!isset($admin['state']) || !$admin['state']){
			return json($admin);
		}
		$data = [
			'start' => input('start'),
			'end' 	=> input('end'),
			'code' 	=> input('code'),
		];
		$res = model('pay')->alipay_report($data);
		if(isset($res['state']) && $res['state']){
			header('Location:'.$res['url']);
	        // header('Location:/home');
	        // die();
			die();
		}
	}
	private function tenpay(){
		$admin = model('admin')->is('finance');
		if(!isset($admin['state']) || !$admin['state']){
			return $admin;
		}
		$data = [
			'start' => input('start'),
			'end' 	=> input('end'),
			'code' 	=> input('code'),
		];
		return model('pay')->tenpay_report($data);
	}
}